/* [Parameters] */
// Here comes the description
// -> lens diameter = inner diameter of lens cover
lensDia = 40.5;
// -> the height of the part that is parallel to the tubus  
height = 10.0;
// -> the height of doom shaped part covering the lens
topRad = 3.0;
// -> wall thickness of lens cover
wall = 2.5;
// -> increase this number for smoother surface
$fn = 120;

//////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////
union()
{
makeLensConver();
makeHolder();
}
//////////////////////////////////////////////////////////////
module makeHolder()
{
translate([lensDia/2+wall-0.3, 0, height/2])
scale([1.0,1.5,1.0])
rotate([0,0,-100])
    {
    rotate_extrude(angle=200, convexity = 10)
    translate([2.5, 0, 0])
    circle(r = wall/2);
    }
}
//////////////////////////////////////////////////////////////
module makeLensConver()
{
    translate([0,0,height])
    rotate([0,180,0])
    difference()
    {
        lensConver(lensDia+2*wall, height, topRad);
        translate([0,0,wall])
        lensConver(lensDia, height, topRad);
    }
}
//////////////////////////////////////////////////////////////
module lensConver(diameter, height, topRadius)
{
    union()
    {
        scale([diameter, diameter, 2*topRadius]) sphere(d=1);
        cylinder(h=height,d=diameter,center=false); 
    }
}
